package vboot.app.module.de.supp.main;

import lombok.Getter;
import lombok.Setter;
import vboot.core.common.entity.BaseMainEntity;
import vboot.core.module.sys.org.root.SysOrg;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

//供应商主信息
@Entity
@Getter
@Setter
public class DeSuppMain extends BaseMainEntity {

    //关联分类表示例
    @Column(length = 32)
    private String catid;//供应商分类

    //流水号示例
    @Column(length = 32)
    private String senum;//流水号

    //数据字典示例
    @Column(length = 32)
    private String level;//供应商资质

    //ManyToOne示例
    @ManyToOne
    @JoinColumn(name = "opman")
    private SysOrg opman;//经办人

    //ManyToMany示例
    @ManyToMany
    @JoinTable(name = "de_supp_viewer", joinColumns = {@JoinColumn(name = "mid")},
            inverseJoinColumns = {@JoinColumn(name = "oid")})
    private List<SysOrg> viewers;//可查看者

    //ManyToMany示例
    @ManyToMany
    @JoinTable(name = "de_supp_editor", joinColumns = {@JoinColumn(name = "mid")},
            inverseJoinColumns = {@JoinColumn(name = "oid")})
    private List<SysOrg> editors;//可编辑者

    //OneToMany示例
    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
    @JoinColumn(name = "maiid")
    @OrderBy("ornum ASC")
    private List<DeSuppContact> contacts = new ArrayList<>();//联系人

    //附件示例
    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
    @JoinColumn(name = "maiid")
    private List<DeSuppAtt> atts = new ArrayList<>();//附件


    //地址选择示例，可根据实际情况存想要的字段
    //region-----地址相关信息-----
    private String addre;//完整地址

    @Column(length = 64)
    private String adreg;//省市区

    @Column(length = 128)
    private String addet;//省市区以外的详细信息

    @Column(length = 32)
    private String adcoo;//经纬度

    @Column(length = 32)
    private String adpro;//省

    @Column(length = 32)
    private String adcit;//市

    @Column(length = 32)
    private String addis;//区
    //endregion
}
